/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Blackjack;

import java.util.List;
import prop.DriverDomainRanking;
import prop.Posicion;

/**
 *
 * @author finfantasy
 */
public class DriverRanking {
    
    private Sistem s;
    private VentSeleccionRanking VSR;
    private DriverDomainRanking DDR;
    private VentResetRanking VRR;
    private int menu;
    public VentRanking VR;

    public DriverRanking(Sistem s, int n) {
        this.s = s;
        menu = n;
    }

    public void mostrarRanking() {
        VSR = new VentSeleccionRanking(this);
        VSR.setEnabled(true);
        s.ocultarMenu();
    }

    public void abrirRanking(int n) {
        if (menu == 1) {
            VSR.setEnabled(false);
            VSR.setVisible(false);
        }
        if (n == 0) DDR = new DriverDomainRanking("LimiteDinero.txt");
        else if (n == 1) DDR = new DriverDomainRanking("LimiteManos.txt");
        else if (n == 2) DDR = new DriverDomainRanking("Libre.txt");
        VR = new VentRanking(this);
        VR.escribeRanking(DDR.cargarRanking());
    }

    public void resetRanking() {
        DDR.resetear();
        VR.escribeRanking(DDR.cargarRanking());
    }

    public void abrirResetRanking() {
        VRR = new VentResetRanking(this);
    }

    public void actualizarRanking(List l) {
        if ((Integer)l.get(0) == 0) DDR = new DriverDomainRanking("LimiteDinero.txt");
        else if ((Integer)l.get(0) == 1) DDR = new DriverDomainRanking("LimiteManos.txt");
        else if ((Integer)l.get(0) == 2) DDR = new DriverDomainRanking("Libre.txt");
        for (int i = 1; i < l.size(); i += 2) {
            DDR.insertar((String)l.get(i), (Integer)l.get(i+1));
        }
    }

    public void volverAlMenu() {
        s.volverAlMenu();
    }

    public void cierraRanking() {
        if (menu == 1) {
            VSR.setVisible(true);
            VSR.setEnabled(true);
        }
        else s.volverAlMenu();
    }

}
